#!/usr/bin/env python
# Copyright (c) 2014, The MITRE Corporation. All rights reserved.
# See LICENSE.txt for complete terms.

import sys
from stix.core import STIXPackage, STIXHeader

def parse_stix( pkg ):
    print "== MALWARE =="
    for ind in pkg.indicators:
        print "---"
        print "Title : " + ind.title
        print "ID : " + ind.id_
        for ind_type in ind.indicator_types:
            print "Type: " + str(ind_type)

        for obs in ind.observables:
            print "URL : " + str(obs.object_.properties.value)

    return 0

if __name__ == '__main__':
    try: fname = sys.argv[1]
    except: exit(1)
    fd = open(fname)
    stix_pkg = STIXPackage.from_xml(fd)

    parse_stix(stix_pkg)
